#include<vector>
using namespace std;
class Solution {
public:
    int findPeakElement(vector<int>& nums) {
        int left = 0, right = nums.size() - 1;
        while(left < right)
        {
            int mid = left + right >> 1;
            if(nums[mid] > nums[right])
            {
                //如果mid比mid+1大，可能是峰值，可以将right置为mid
                if(nums[mid] > nums[mid + 1]) right = mid;
                else left = mid + 1;
            }
            else left = mid + 1;
        }
        return left;
    }
};